import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Game {

	private static final int RESULT_3 = 3;
	private static final int RESULT_2 = 2;
	private static final int RESULT_1 = 1;
	private static final String DESC1 = "What class would you like to be?";
	private static final String DESC2 = "1.Mage";
	private static final String DESC3 = "2.Barbarian";
	private static final String DESC4 = "3.Thief";
	private static final String DESC5 = ". make a text based game";
	private static final String DESC6 = " ";

	private static final String DESC9 = "What would you like to call the character?";
	private static final String TERM_ARROW = ">";
	
    public String input = null;
	private static String result = null;
	public String characterName = null;
	public String enter = null;

	public void nameEntry() {
		System.out.println(DESC9);
		System.out.print(TERM_ARROW);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			characterName = br.readLine();
		} catch (IOException ioe) {
			System.out.println("IO error trying to read your name!");
		}
	}
	
	

	
	public int chooseCharacter() {
		
		System.out.println("Choose a character type");
		System.out.println("1. Thief");
		System.out.println("2. Warrior");
		System.out.println("3. Wizard");
		System.out.print(TERM_ARROW);
		
		String characterChoice = null;
		boolean exceptionHappened = false;
		boolean redoloop = false;
		
		do{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			exceptionHappened = false;
			redoloop = false;
			
			try {
				characterChoice = br.readLine();
			} catch (IOException ioe) {
				System.out.println("IO error trying to read your name!");
			}
			
			try {
				Integer.parseInt(characterChoice);
			} catch (NumberFormatException exception) {
				exceptionHappened = true;
				System.out.println("Couldn't convert that to a number");
			}
			
			if(exceptionHappened){
				redoloop = true;
			}

			if(redoloop != true){
				if(Integer.parseInt(characterChoice) != 1 || Integer.parseInt(characterChoice) != 2  || Integer.parseInt(characterChoice) != 3){
					redoloop = false;
				}else{
					redoloop = true;
				}	
			}
			
			
		}while (redoloop == true);
		
		
		return Integer.parseInt(characterChoice);
	}

	public void startThiefGame() {
		// TODO Auto-generated method stub
			System.out.println("Yes... " + characterName + " the Thief");
			System.out.println("His is a tale of adventure and heroism.");
			System.out.println("Let us begin...");
			System.out.println("After years of living off of others wealth and riches,");
			System.out.println("our friend " + characterName + " was finally apprehended");
			
			System.out.print(TERM_ARROW);		
			
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			try {
				enter = br.readLine();
			} catch (IOException ioe) {
				System.out.println("IO error trying to read your name!");
			}
			System.out.println("");
			System.out.println("And this is where we join our would be hero");
			System.out.println("lying in a foul prison waiting for his execution");
			System.out.println("That or a miracle...");
            System.out.print(TERM_ARROW);		
            

			try {
				enter = br.readLine();
			} catch (IOException ioe) {
				System.out.println("IO error trying to read your name!");
			}
			System.out.println("");
			System.out.println("Jailor: Im lookin right forward to watching you swingin by your neck runt.");
			System.out.println("");
			System.out.println("1. Sorry could you repeat that without the bombardment of saliva?");
			System.out.println("2. How about you come in here at say that fatboy.");
			System.out.println("3. ...");
			System.out.print(TERM_ARROW);
			
			BufferedReader enter = new BufferedReader(new InputStreamReader(System.in));
			
			try {
				input = enter.readLine();
			} catch (IOException ioe) {
				System.out.println("IO error trying to read your name!");
			}
			
			switch (Integer.valueOf(input).intValue()) {
			case RESULT_1:	System.out.println("");
				            System.out.println(characterName + ": Sorry could you repeat that without the bombardment of saliva?");
				            System.out.println("Jailor: What you say deadmeat! Want me to come bash your face in?");
				            continueThiefGame();
					break;
			case RESULT_2:  System.out.println("");
				            System.out.println(characterName + ": How about you come in here and say that fatboy.");
				            System.out.println("Jailor: Lets see how you like the taste of my foot!");
				            continueThiefGame();
					break;
			case RESULT_3:  System.out.println("");
				            System.out.println(characterName + ": ...");
				            System.out.println("Jailor: Aww poor little kitten scared, bet my fist cheers you right up!"); 
				            continueThiefGame();	
					break;}
		}
	
	

	public void startWarriorGame() {
		// TODO Auto-generated method stub
		
			System.out.println("Yes... " + characterName + " the Warrior");
			System.out.println("His is a tale of adventure and heroism.");
			System.out.println("Let us begin...");
			System.out.println(DESC2);
			System.out.println(DESC3);
			System.out.println(DESC4);
			System.out.print(TERM_ARROW);		
			
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			try {
				characterName = br.readLine();
			} catch (IOException ioe) {
				System.out.println("IO error trying to read your name!");
			}
		}
	

	public void startWizardGame() {
		// TODO Auto-generated method stub
		
			System.out.println("Yes... " + characterName + " the Wizard");
			System.out.println("His is a tale of adventure and heroism.");
			System.out.println("Let us begin...");
			System.out.println(DESC2);
			System.out.println(DESC3);
			System.out.println(DESC4);
			System.out.print(TERM_ARROW);		
			
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			try {
				characterName = br.readLine();
			} catch (IOException ioe) {
				System.out.println("IO error trying to read your name!");
			}}
	

	public void continueThiefGame() {
		System.out.println("");
		System.out.println("*The Jailor's sweaty hands thumb through his keyring looking for the right one,*");
		System.out.println("*A sick smile comes across his face when he finds it and enters your cell,*");
		System.out.println("*Suddenly as he edges towards you...*");
		System.out.print(TERM_ARROW);
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			enter = br.readLine();
		} catch (IOException ioe) {
			System.out.println("IO error trying to read your name!");
		}
		System.out.println("");
		System.out.println("Stranger: What do you think your doing?");
		System.out.println("Jailor: Sire! I was just..he...");
		System.out.println("Stranger: Get out, il deal with your later. Now go!");
		System.out.println("*The Jailor flees the cell while keeping his eyes off the stranger*");
		System.out.print(TERM_ARROW);		
        

		try {
			enter = br.readLine();
		} catch (IOException ioe) {
			System.out.println("IO error trying to read your name!");
		}
		System.out.println("");
		System.out.println("Stranger: I do apologise for that and let me introduce myself");
		System.out.println("I am King Faxess the Third.");
		System.out.println("I have no doubt you know that, seeing as you've stole half my castle over the last few years");
        System.out.print(TERM_ARROW);		
        

		try {
			enter = br.readLine();
		} catch (IOException ioe) {
			System.out.println("IO error trying to read your name!");
		}
		System.out.println("");
		System.out.println("King Faxess: Let me make this brief, i have a proposal for someone of your talents.");
		System.out.println("Far from here over the Earths scar there is a Fortress.");
		System.out.println("This Fortress is not of todays folk but of long ago's.");
		System.out.println("My scholars tell me of treasures hidden deep within this domain...");
		System.out.println("but they also warn me of the dangers");
        System.out.print(TERM_ARROW);		
        

		try {
			enter = br.readLine();
		} catch (IOException ioe) {
			System.out.println("IO error trying to read your name!");
		}
		System.out.println("");
		System.out.println("King Faxess: I care not for the old mens rantings of demons and kings past.");
		System.out.println("But traps there are many, few of the cowards i sent out returned");
		System.out.println("and those that did went insane with what they had seen.");
		System.out.print(TERM_ARROW);		
        

		try {
			enter = br.readLine();
		} catch (IOException ioe) {
			System.out.println("IO error trying to read your name!");
		}
		System.out.println("");
		System.out.println("King Faxess: My scholars books speak of a Talisman...");
		System.out.println("I would like for you to enter this haven of traps overcome them and");
		System.out.println("obtain this Talisman for me.");
		System.out.println("");
		System.out.println(characterName + ": Why should i do any of this for you?");
		System.out.print(TERM_ARROW);		
        

		try {
			enter = br.readLine();
		} catch (IOException ioe) {
			System.out.println("IO error trying to read your name!");
		}
		System.out.println("");
		System.out.println("*King Faxess laughs to himself*");
		System.out.println("King Faxess: Your other choice is death and a slow one at that.");
		System.out.println("I feel no need to send someone who angers me to the gallows,");
		System.out.println("not when i have such talented artists in the dungeon quarters.");
	    System.out.print(TERM_ARROW);		
        

		try {
			enter = br.readLine();
		} catch (IOException ioe) {
			System.out.println("IO error trying to read your name!");
		}
		System.out.println("");
		System.out.println("King Faxess: So what shall it be?");
		System.out.println("1. Fine il get your talisman");
		System.out.println("2. I was always interested in art i think il enjoy my stay here");
	    System.out.print(TERM_ARROW);		

		
		BufferedReader enter = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			input = enter.readLine();
		} catch (IOException ioe) {
			System.out.println("IO error trying to read your name!");
		}
		
		switch (Integer.valueOf(input).intValue()) {
		case RESULT_1:	System.out.println("");
			            System.out.println("King Faxess: Excellent, come with me and we shall talk this over some more");
			            System.out.println("");
			            System.out.println("~ After being recruited by the King and armed with his tools " + characterName);
			            System.out.println("started on his journey with nothing hoping to return with everything...");
			            thiefGameChapterOne();
				break;
		case RESULT_2:  System.out.println("");
			            System.out.println("King Faxess: I am dissapointed to say the least but im sure il find another with time");
			            System.out.println("");
			            System.out.println("~ "+characterName+" sufferend many lifetimes worth of pain in the dungeons");
			            System.out.println("of King Faxess's Castle, his screams would light up the village at night.");
			            System.out.println("As time went by " + characterName + " deeply regretted his choice.~");
			            
				break;}
	}

    public void thiefGameChapterOne() {
        System.out.print(TERM_ARROW);
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			enter = br.readLine();
		} catch (IOException ioe) {
			System.out.println("IO error trying to read your name!");
		}
		
    	System.out.println("");
    	System.out.println("~After four days of walking our friend " + characterName + " finally arrives to");
    	System.out.println("the blackened doors of the Fortress, about the door lay the ruined bodies of fallen men.");
    	System.out.println("Let us hope his fate walks another path...");
    	
    }}
     



